package com.scott.aop.aspect;



import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class AnnotationLogAspect {

    private final static Logger log = Logger.getLogger(LogAspect.class);

    @Pointcut("execution(* com.scott.aop.service..*(..))")
    public void pointCutConfig(){}

    @Before("pointCutConfig()")
    public void before(JoinPoint joinPoint) {
        log.info("调用方法之前执行" + joinPoint);
    }

    @After("pointCutConfig()")
    public void after(JoinPoint joinPoint) {
        log.info("调用方法之后执行" + joinPoint);
    }


    @AfterReturning("pointCutConfig()")
    public void afterReturn(JoinPoint joinPoint) {
        log.info("调用方法获得返回值之后" + joinPoint);
    }

    @AfterThrowing("pointCutConfig()")
    public void afterThrow(JoinPoint joinPoint) {
        log.info("抛出异常之后执行" + joinPoint);
    }


}

